<?php

namespace plugins\guestbook\controller;

use cmf\controller\PluginBaseController;
use plugins\guestbook\Model\PluginGuestbookModel;
use plugins\guestbook\Validate\GuestbookValidate;
use think\Db;

class IndexController extends PluginBaseController
{


    /**
     * 提交留言
     * @adminMenu(
     *     'name'   => '添加页面提交',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '添加页面提交',
     *     'param'  => ''
     * )
     */
    public function addMsg()
    {
        $data              = $this->request->param();

        $result = $this->validate($data, 'Guestbook');

        if ($result !== true) {
            $this->error($result);
        }

//        if($result){
//            dump($guestbookValidate->getError());
//        }


        $GuestbookModel = new PluginGuestbookModel();


//        $data['user_id'] = cmf_get_current_admin_id();
//
//
//        $data['post_status'] = empty($data['post_status']) ? 0 : 1;
//        $data['post_type']   = 2;
//        $this->allowField(true)->data($data, true)->save();

        $this->success('提交成功！');
//
//
//
//        $this->success(lang('ADD_SUCCESS'), url('AdminPage/edit', ['id' => $portalPostModel->id]));

    }

}
